/**
 * 购物车
 */

import request from "@/utils/request";

// 获取一级分类列表
export const getCartItems = (userId) => {
  return request({
    method: "GET",
    url: "/cart/getCartItems",
    params: {
      userId,
    },
  });
};

// 改变某件商品的选中状态
export const changeChecked = (data) => {
  return request({
    method: "PUT",
    url: "/cart/changeChecked",
    data,
  });
};

// 改变所有商品的选中状态
export const changeAllChecked = (data) => {
  return request({
    method: "PUT",
    url: "/cart/changeAllChecked",
    data,
  });
};

// 删除购物车中的商品
export const deleteCartGoods = (data) => {
  return request({
    method: "DELETE",
    url: "/cart/deleteCartGoods",
    data,
  });
};

// 修改购物车中商品的数量
export const updateGoodsAmount = (data) => {
  return request({
    method: "PUT",
    url: "/cart/updateGoodsAmount",
    data,
  });
};

// 加入商品到购物车
export const addGoodsToCart = (data) => {
  return request({
    method: "POST",
    url: "/cart/addGoodsToCart",
    data,
  });
};
